package zucc.edu.cn.chengchengparttime.Workdetails;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.widget.ImageView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

import zucc.edu.cn.chengchengparttime.MainActivity;
import zucc.edu.cn.chengchengparttime.My.MyAppSetting;
import zucc.edu.cn.chengchengparttime.R;
import zucc.edu.cn.chengchengparttime.Text;

public class WorkdetailsActivity extends AppCompatActivity {
    private Context context;
    RecyclerView rv; //RecyclerView布局
    WorkdetailsAdapter workdetailsAdapter; //适配器
    List<Text> data=new ArrayList<>(); //数据列表
    private ImageView goback;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_workdetails_main);
        context = this.getBaseContext();

        Text t=new Text("图书馆图书整理","校内 | 图书馆","15/小时");
        data.add(t);
        Text t2=new Text("整理图书馆二楼的图书","tip:凡涉及到工作内容不符，收费、违法信息传播的工作，请您警惕并收集关联证据向我们举报"
                ,"周一13:00-17:00","浙大城市学院体育室","陈老师","86");
        data.add(t2);

        //配置布局管理器、分割线、适配器
        rv = (RecyclerView) findViewById(R.id.rv);
        //第一步：设置布局管理器
        rv.setLayoutManager(new LinearLayoutManager(this));
        //第三步：设置适配器
        workdetailsAdapter=new WorkdetailsAdapter(this,data);
        rv.setAdapter(workdetailsAdapter);

        goback=findViewById(R.id.goback);
        goback.setOnClickListener(view -> {
            Toast.makeText(this.context, "点击了返回按钮" , Toast.LENGTH_SHORT).show();
            //跳转到首页（首先要跳转到MainActivity，然后跳转到HomeFragment）
            Intent i=new Intent();
            i.setClass(WorkdetailsActivity.this, MainActivity.class);
            //一定要指定是第几个pager，这里填写1
            i.putExtra("id",1);
            startActivity(i);
        });
    }
}
